<template>
  <f7-page   @page:reinit="getDataItems"   >
    <f7-navbar title="吉林动画学院红头文件申请表" back-link="Back"></f7-navbar>


    <f7-list inline-labels no-hairlines-md>
      <f7-list-item title="名    称" v-bind:after="item.title"></f7-list-item>
      <f7-list-item title="创建时间" v-bind:after="item.creationDate"></f7-list-item>
      <f7-list-item title="申请部门" v-bind:after="item.orgName"></f7-list-item>
      <f7-list-item title="申请时间" v-bind:after="item.updateDate"></f7-list-item>
      <f7-list-item title="文    号" v-bind:after="item.businessNo"></f7-list-item>
      <f7-list-item title="文号类型" v-bind:after="getDocTypeName(item.docType)"></f7-list-item>
      <f7-list-item title="文件状态" v-bind:after="item.docStatus"></f7-list-item>
      <f7-list-item title="申 请 人" v-bind:after="item.createBy"></f7-list-item>

      <f7-list-item>
        <f7-label>发文内容</f7-label>
        <f7-input type="textarea" disabled v-bind:value="item.docContent"></f7-input>
      </f7-list-item>
      <f7-list-item>
        <f7-label>需要审批</f7-label>
        <f7-toggle disabled color="orange" :checked="item.needHeader"></f7-toggle>
      </f7-list-item>
    </f7-list>

    <f7-list inline-labels no-hairlines-md v-show="item.needHeader">.
      <f7-list-item title="校领导审批名单" v-bind:after="item.needManagerUser"></f7-list-item>
      <f7-list-item title="部门负责人签字" v-bind:after="item.depUser"></f7-list-item>
      <f7-list-item title="校务部签字" v-bind:after="item.schoolUser"></f7-list-item>
      <f7-list-item title="校领导签字" v-bind:after="item.managerUser"></f7-list-item>
      <f7-list-item title="董事长签字" v-bind:after="item.chairmanUser"></f7-list-item>
    </f7-list>

    <f7-block-title></f7-block-title>
    <f7-list accordion >
      <f7-list-item title="流程历史" v-bind:link="'/oa/activities/' + item.processInstanceId"></f7-list-item>
      <f7-list-item title="附件数据" v-bind:link="'/oa/attachments/' + item.id"></f7-list-item>
      <f7-list-item accordion-item  id="m2"  :accordion-item-opened="true" title="业务审批" v-show="paramsId ==-1 ? false : true">
        <f7-accordion-content>
          <f7-block>
            <f7-list inline-labels no-hairlines-md>
              <f7-list-item>
                <f7-input type="textarea" placeholder="请在这里填写批注" v-bind:value="admitData.comment"  @input="admitData.comment =  $event.target.value"></f7-input>
              </f7-list-item>
              <f7-list-item>
                <img slot="media" v-bind:src="admitData.signature" />
              </f7-list-item>
            </f7-list>
            <f7-button raised href="/oa/personalwork/signature" >手写签名</f7-button>

            <f7-block strong>
              <f7-row>
                <f7-col width="50">
                  <f7-button fill raised @click="superiorDecision('同意')">同意</f7-button>
                </f7-col>
                <f7-col width="50">
                  <f7-button fill raised color="red" @click="superiorDecision('不同意')">不同意</f7-button>
                </f7-col>
              </f7-row>
            </f7-block>
          </f7-block>
        </f7-accordion-content>
      </f7-list-item>

    </f7-list>
  </f7-page>
</template>

<script>

  export default {
    name: "admitPageLow1",
    data() {
      return {
        item: {},

        admitData: {
          signature: "",
          accepted: "不同意",
          comment: "",
          taskId: 0,
        },
        paramsEntityId: this.$f7route.params.entityId,
        paramsId: this.$f7route.params.id,
        issueNum: this.GLOBAL.issueWord,
      }
    },
    mounted() {
      this.$f7ready((f7) => {
        let that = this;
        let url = that.GLOBAL.RequestAddress + '/camel/rest/redheadapplys/' + that.paramsEntityId;
        f7.request.setup({
          headers: {
            'AccessToken': sessionStorage.getItem('accessToken'),
            'JSESSIONID': sessionStorage.getItem('userToken')
          }
        });
        f7.request.json(url, {}, function (result) {
          console.log('result:', result)
          that.item = result;
        });


      });
    },
    computed: {},
    methods: {
      getDocTypeName: function (num) {
        let that = this;
        return that.issueNum[num];
      },
      getDataItems: function () {
        let that = this;
        let app = that.$f7;
        let url = that.GLOBAL.RequestAddress + '/camel/rest/redheadapplys/' + that.paramsEntityId;
        app.request.json(url, {}, function (result) {
          console.log('result:', result)
          that.item = result;
        })
        that.showSignaure();
      },
      superiorDecision: function (opinion) {
        let that = this;
        let app = that.$f7
        let url = that.GLOBAL.RequestAddress + "/camel/rest/redheadapplys/workflow/completeTask"
        that.admitData.taskId = that.paramsId;
        that.admitData.accepted = opinion;
        //console.log(opinion)
        app.request.json(url, that.admitData, function (result) {
          that.showAlert("提示", result.msg);
        })
      },
      showAlert: function (title, text) {
        let that = this;
        let app = that.$f7
        app.dialog.alert(text, title, () => {
          //that.popupOpened = false
          that.$f7router.back();
        });
      },

      showSignaure : function () {
        let that = this;
        that.admitData.signature = that.$f7.data.admitSig;
        that.$f7.data.admitSig = "";
      },

    }
  }
</script>

<style scoped>

</style>
